#-------------------------------------------------------------------------------
# Name:        settings
# Purpose:     Manage settings file and during importing check if path to the
#              blast, clustalomega and mapp is set correctly.
#              If path in settings file isn't correct, then raises IOError exception.
#               This settings are available:
#               remote - Bool
#               databaseDir - str path
#               blast - str path
#               clustalomega - str path
#               sempy - str path
#               mapp - str path
#               msafile - str path
#               treefile - str path
#               mappfile - str path
#               removefiles - Bool
#
# Author:      Bc. Ondrej Pelikan
#
# Created:     04.04.2013
#-------------------------------------------------------------------------------

#settings variables



# parse settings file
import os, ConfigParser

settingsPath =  "settings"

sectionPath =   "programs"
sectionProgramfiles = "programfiles"

blastRemote = "blast_remote"
blastDatabaseDir = "blast_database_dir"

blastName = "blast"
clustalOName = "clustalo"
mappName = "mappjar"
clustalWName = "clustalw"
tcoffeeName = "tcoffee"
mafftName = "mafft"
muscleName = "muscle"
phymlName = "phyml"
probconsName = "probcons"


msafileName = "msafile"
treefileName = "treefile"
mappfileName = "mappfile"
removefilesName = "remove"

packageDir = os.path.dirname(__file__) + "/"
settings = ConfigParser.SafeConfigParser()
settings.readfp(open(packageDir + settingsPath))

remote =        settings.getboolean(sectionPath, blastRemote)
databaseDir =   settings.get(sectionPath, blastDatabaseDir)
blast =         settings.get(sectionPath, blastName)
clustalomega =  settings.get(sectionPath, clustalOName)
mapp =          settings.get(sectionPath, mappName)
clustalw =      settings.get(sectionPath, clustalWName)
tcoffee =       settings.get(sectionPath, tcoffeeName)
mafft =         settings.get(sectionPath, mafftName)
muscle =        settings.get(sectionPath, muscleName)
phyml =         settings.get(sectionPath, phymlName)
probcons =      settings.get(sectionPath, probconsName)

msafile =       settings.get(sectionProgramfiles, msafileName)
treefile =      settings.get(sectionProgramfiles, treefileName)
mappfile =      settings.get(sectionProgramfiles, mappfileName)

removefiles = settings.getboolean(sectionProgramfiles, removefilesName)




